package utils

import (
	"bytes"
	"github.com/golang/protobuf/jsonpb"
	"github.com/golang/protobuf/proto"
)

func TransProtoToJson(pb proto.Message) string {
	var pbMarshaler jsonpb.Marshaler
	pbMarshaler = jsonpb.Marshaler{
		EmitDefaults: true,
		OrigName:     true,
		EnumsAsInts:  true,
	}
	_buffer := new(bytes.Buffer)
	_ = pbMarshaler.Marshal(_buffer, pb)
	return string(_buffer.Bytes())
}
